<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String basePath = request.getContextPath();
	String path = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+basePath+"/";
	request.setAttribute("path",path);
%>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no,address=no,email=no"/>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>虎丘婚纱城在线商城_注册</title>
	<script type="text/javascript" src="${path}/mobileTerminal/js/jquery.js"></script>
	<script type="text/javascript" src="${path}/js/jquery-2.1.1.min.js"></script>
	<link href="${path}/mobileTerminal/css/style.css" rel="stylesheet" media="all">
	<link rel="shortcut icon" href="${path}/mobileTerminal/img/favicon.png">
</head>
<script>

    function register() {
        /*var captcha = document.getElementById("captcha").value;*/
        var yzm = document.getElementById("yzm").value;
        var password = document.getElementById("password").value;
        if (password==""){
            alert("密码为空!");
		}
        if (yzm == "") {
            alert("验证码为空!");
        }else {
            document.form1.action = "${path}/saveRegister";
            document.form1.submit();
        }
		/* 查出resp的值并弹框  */
    }
    var InterValObj; //timer变量，控制时间
    var count = 60; //间隔函数，1秒执行
    var curCount;//当前剩余秒数
    function captchasend() {
        curCount = count;
        var phone = document.getElementById("phone").value;
		/*var partten = /^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/;*/
        var partten = /^1[3|4|5|7|8][0-9]\d{4,8}$/
        if (phone == "" || !partten.test(phone)) {
            alert("号码不正确!");
        } else {

            $("#yzm_but").attr("disabled", "true");
            $("#yzm_but").val("重新获取(" + curCount + ")");
            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
            $.ajax({
                type: 'post',
                url: "${path}/captcha_send",
                data: {"phone": phone},
				/*contentType: 'application/json',
				 dataType: 'json',*/
                success: function (msg) {
					/*console.log(msg);
					 if (msg.code == 200) {
					 self.get();
					 self.hidelayout();
					 }*/
//					alert("获取验证码成功 请稍后。。");
                }
            })
        }


    }
    //timer处理函数
    function SetRemainTime() {
        if (curCount == 0) {
            window.clearInterval(InterValObj);//停止计时器
            $("#yzm_but").removeAttr("disabled");//启用按钮
            $("#yzm_but").val("重新获取验证码");
        }
        else {
            curCount--;
            $("#yzm_but").val("重新获取(" + curCount + ")");
        }
    }
    function checkForm() {
        var flag = true;
        var resp = form1.resp.value;
        if (resp != "null"&& resp!=null&&resp!="") {
            if (resp != 'resp') {
                alert(resp);
                flag = false;
            }
        }
        return flag;
    }

</script>
<body class="hu_shopping" onload="checkForm()">
	<header>
		<div class="headerwrap">
			<div class="header_wrap">
				<a href="javascript:history.go(-1);" class="return_last">返回</a>
				<h1>注册</h1>
			</div>
		</div>
	</header><!-- header -->
	<form id="form1" name="form1" method="post" action="" class="logreg_form">
		<input id="captcha" name="captcha" style="display: none" value="${captcha}">
		<input id="resp" name="resp" style="display: none" value="${resp}">
	<div class="content_wrap login_register" id="register_wrap">
		<div class="logo_wrap"><a href="#"><img src="${path}/img/logo.png"></a></div><!-- logo_wrap -->
<p class="form_txt">
<input value="${phone}" type="number" name="phone" id="phone" required="required" onfocus="document.getElementById('zcdn_note').style.display='none'" onblur="if(value=='')document.getElementById('zcdn_note').style.display='block'">
	<%--<span id="zcdn_note" class="form_note">输入手机号码</span>--%>
	<c:if test="${phone =='null'}">
	<span id="zcdn_note" class="form_note">输入手机号码</span>
</c:if>
</p>
<p class="form_txt">
	<c:choose>
		<c:when test="${password == 'null'}">
			<input value="" type="password" name="password" id="password" onfocus="document.getElementById('zcmma_note').style.display='none'" onblur="if(value=='')document.getElementById('zcmma_note').style.display='block'">
		</c:when>
		<c:otherwise>
			<input value="${password}" type="password" name="password" id="password" onfocus="document.getElementById('zcmma_note').style.display='none'" onblur="if(value=='')document.getElementById('zcmma_note').style.display='block'">
		</c:otherwise>
	</c:choose>
	<%--<span id="zcmma_note" class="form_note">请输入密码</span>--%>
	<c:if test="${password == 'null'}">
	<span id="zcmma_note" class="form_note">请输入密码</span>
	</c:if>
</p>
<p class="form_txt yz_txt">
<input value="" type="number" name="yzm" id="yzm" onfocus="document.getElementById('yzm_note').style.display='none'" onblur="if(value=='')document.getElementById('yzm_note').style.display='block'">
<span id="yzm_note" class="form_note">输入短信验证码</span>
<input class="yzm_but" id="yzm_but" type="button" onclick="captchasend(this)" value="获取验证码" />
</p>
			<p class="login_button">
				<input class="register_but" id="register_but" type="button" onclick="register()" value="提交" />
			</p>

	</div>
	</form><!-- content_wrap -->
	
	<div class="footer_copyright">
		<p>苏州知行合一网络科技有限公司提供技术支持</p>
	</div><!-- footer_copyright -->
	
	 <script type="text/javascript">
		/*$(function () {
                $('.register_but').click(function(){
                   var phoneNumber=/^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/,
                            idCardNo=/^\d{15}(\d{2}(\d|x))?$/i;
                    var zcdn = $.trim($('#zcdn').val());// 电话

                    if(!phoneNumber.test(zcdn)){
                        alert('请输入正确的手机号码!');
                        ajaxStatus = true;
                        return false;
                    }
					
					var zcmma = $('#zcmma').val();
                    if(zcmma == '') {
                        alert("请输入密码");
                        return false;
                    }
					
					var yzm = $('#yzm').val();
                    if(yzm == '') {
                        alert("请输入短信验证码");
                        return false;
                    }

                    $('#register_form').submit();
                })
            });*/
    </script>
</body>
</html>